Tom,
Thanks!!! It works great. (Other than not being successful at adding a forever loop in my init file and making it work through my init file). I was able to add a foreverloop that ran thread1 continuously, but it didn't like how I added servicechargepump().
I have had the same issue with adding cssjog.c , so I just believe I am of course doing something wrong/don't get it.
My error with adding servicechargepump() to for(;;) is "Undefined symbol servicechargepump' "
Cssjog.c implementation is a low priority, but it seems to be a great example as to how to add a continuous loop as you have all the notes in there.
This charge pump is more of a priority.
I think I am missing the big picture on how a continuous loop works. Does the init file thread1 continuous loop "servischargepump()' call and initiate thread5 (my thread 5 is what you sent me)? Or do I put the that servicechargepump.c file you provided in thread1?
I have tried this in many ways.... (Point is I followed the format example from cssjog.c)
I will have to send you my init file tonight, but thought you might have some suggestions/posts for me to read in the meantime. I couldn't find any solutions on the forum that worked for me.
A great respect to what you do and provide.(and all other programmers too).
Thanks,
Rob
Thanks Tom,
I'll give it a go and see what happens (with my lack of c knowledge and abundance of curiosity/drive to get this done)
I'll attach files next time. Unfortunately most of my posts are on my phone... Ya, that looks terrible.
Thanks so much for being so patient and your help!
Rob
Hi Rob,
See attached program. As long as ServiceChargePump() is being called (add to a forever loop in your Initialization Program) then turning on and off IO Bit 46 (KFLOP LED) should activate and deactivate the charge pump.
Please attach C files to post in the future otherwise the formatting gets messed up in the email.
HTH Regards TK
Group: DynoMotion |
Message: 10128 |
From: Tom Kerekes |
Date: 9/4/2014 |
Subject: Re: Pwm and chargepump |
Hi Rob,
You must merge the function ServiceChargePump() into your Init file in order to be able to call that function (only the function not the entire file).
A function is similar to a subroutine. Functions can be added before or after the main function. I like to add them at the end of the file because I think that is more logical and readable. But the Compiler only works in a single pass from top to bottom and likes to know the name of any functions, and what parameters are supposed to be supplied for the function, before it sees a call to the function. So a "prototype" of the function should be placed up near the beginning of the file to declare it to the compiler. The
prototype is the same as the actual function but with the body removed and replaced with a semicolon. The file I supplied (that you are running and testing in Thread 5) had that same structure: Prototype near the beginning, main function, ServiceChargePump() function at the end.
HTH Regards TK
From: "Rjreese29 rjreese29@... [DynoMotion]" <DynoMotion@yahoogroups.com> To: "DynoMotion@yahoogroups.com" <DynoMotion@yahoogroups.com> Sent: Thursday, September 4, 2014 12:04 PM Subject: Re: [DynoMotion] Re: Pwm and chargepump
Tom,
Thanks!!! It works great. (Other than not being successful at adding a forever loop in my init file and making it work through my init file). I was able to add a foreverloop that ran thread1 continuously, but it didn't like how I added servicechargepump().
I have had the same issue with adding cssjog.c , so I just believe I am of course doing something wrong/don't get it.
My error with adding servicechargepump() to for(;;) is "Undefined symbol servicechargepump' "
Cssjog.c implementation is a low priority, but it seems to be a great example as to how to add a continuous loop as you have all the notes in there.
This charge pump is more of a priority.
I think I am missing the big picture on how a continuous loop works. Does the init file thread1 continuous loop "servischargepump()' call and initiate thread5 (my thread 5 is what you sent me)? Or do I put the that servicechargepump.c file you provided in thread1?
I have tried this in many ways.... (Point is I followed the format example
from cssjog.c)
I will have to send you my init file tonight, but thought you might have some suggestions/posts for me to read in the meantime. I couldn't find any solutions on the forum that worked for me.
A great respect to what you do and provide.(and all other programmers too).
Thanks,
Rob
Thanks Tom,
I'll give it a go and see what happens (with my lack of c knowledge and abundance of curiosity/drive to get this done)
I'll attach files next time. Unfortunately most of my posts are on my phone... Ya, that looks terrible.
Thanks so much for being so patient and your help!
Rob
Hi Rob,
See attached program. As long as ServiceChargePump() is being called (add to a forever loop in your Initialization Program) then turning on and off IO Bit 46 (KFLOP LED) should activate and deactivate the charge pump.
Please attach C files to post in the future otherwise the formatting gets messed up in the email.
HTH Regards TK
Hi Tom,
Here is a bit better of a question.
How would you go about gaining control over turning the below program on and off with a bit?
The below program is working for me now, but I just cannot gain io control over it
I will be also implementing externalbuttons.c , so I am thinking estop function in this program might help me get there easier. Use estop function in this program to also stop the stepaspwm.c from stepping.
#include "KMotionDef.h"
// Example showing how any of the 8 Step and Direction
// frequency generators may be used as a PWM
//STEP_RATE_ADD 0x3c - write a 32 bit word - Bit31=enable, Bit27=Drive, Bits24-26=chan, 0-23= signed fraction of 16.666MHz
//STEP_PULSE_LENGTH_ADD 0x06 - write a 6 bit word - 0-63 = # of 16.666MHz clocks to this address
#define CLOCK 16.6666e6
main()
{
double DutyCycle, Period;
int Frequency;
int Pulse=50; // Fixed pulse length of 50/16.66MHz = 2us
int StepChan = 4; // KFLOP Step Gen 4 IO10 Pin 36 - when high(1), this turns on the C4 Safety Charge pump for supermax
SetBitDirection(36,1);
FPGA(STEP_PULSE_LENGTH_ADD) = Pulse;
DutyCycle= 0.33; // Note Duty Cycle can't be zero (useful range 0.02 - 0.98)
Period = Pulse/DutyCycle;
Frequency = (int)(0x7FFFFF/Period);
printf("DutyCycle=%f, Pulse=%d clocks, Period=%f clocks\n",DutyCycle,Pulse,Period);
FPGA(STEP_RATE_ADD+0) = Frequency; // put 23 bit frequency
FPGA(STEP_RATE_ADD+1) = Frequency>>8;
FPGA(STEP_RATE_ADD+2) = Frequency>>16;
FPGA(STEP_RATE_ADD+3) = 0x88 + StepChan; // combine enable, Drive High and low mode, channel
}
Thanks Tom!!
Rob
|
|
| |